package org.nowcoder.huawei.c200;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * 46：贪吃的猴子
 */
public class HC046 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //数组的长度
        int n = Integer.parseInt(br.readLine());

        //香蕉的熟练
        int[] numbers = new int[n];
        String[] strs = br.readLine().split(" ");
        for (int i = 0; i < strs.length; i++) {
            numbers[i] = Integer.parseInt(strs[i]);
        }

        //获取的次数
        int m = Integer.parseInt(br.readLine());
        maxBananas(numbers, m);
    }

    public static void maxBananas(int[] numbers, int m) {
        //滑动窗口
        int n = numbers.length - m;
        int sum = 0;
        int left = 0, right = n;
        for (int i = 0; i < right; i++) {
            sum += numbers[i];
        }
        int min = sum;

        while (right < numbers.length) {
            sum += numbers[right++];
            sum -= numbers[left++];
            min = Math.min(min, sum);
        }

        int all = Arrays.stream(numbers).sum();
        System.out.println(all - min);
    }
}
